<%@page import="java.util.Date"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:useBean id="edittingOrg"
	class="team02.server.bean.OrganizationBean" scope="page"></jsp:useBean>
	
<script>
	function check_selected() {
		var test = document.getElementsByName("selected_id");
		var sizes = test.length;
		for ( var i = 0; i < sizes; i++)
			if (test[i].checked)
				return true;
		alert("一つの団体を選択してください！");
		return false;
	}
	function check_delete() {
		if (check_selected()) {
			if (confirm("本当にこの団体を削除したいですか")) {
				return true;
			}
		}
		return false;
	}
</script>

<link href="${pageContext.request.contextPath}/css/org_manager.css"
	rel="stylesheet" type="text/css" />
<%
//権限をチェック
if(userBean.getAccessLevel()!=1){
	response.sendRedirect("404.html");
	return;
}
%>


<c:set value="<%=orgBean.listAllOrganization()%>" var="listOrg"></c:set>
<div class="menu1"><%@include file="/jsputils/menu.jsp"%>
	<div class = "greeting_message">
		<%@include file="/jsputils/greeting.jsp"%>
	</div>
</div>
<div class="container">

<form action="" method="post" name="form">
	<div class="menu">
		<p class="menu_label">団体管理者</p>
		<p class="menu_item">
			<button type="submit" formaction="org_add.t02">新規追加</button>
			<button type="submit" formaction="org_edit.t02"
				onclick="return check_selected()">編集</button>
			<button type="submit" formaction="org_delete.t02"
				onclick="return check_delete()">削除</button>
			<button type="submit" formaction="org_trash.t02">トラッシュ</button>
		</p>
	</div>
	<div >
		<table class="table_content">
			<tr>
				<th></th>
				<th>団体名</th>
				<th>アドレス</th>
				<th>登録日</th>
				<th>期限日</th>
				<th>alias</th>
				<th>管理者名</th>
				<th>メール</th>

			</tr>
			<c:forEach var="orgItem" items="${listOrg}">
				<tr>
					<td><input type="radio" name="selected_id"
						value="${orgItem.alias}"></td>
					<td>${orgItem.name}</td>
					<td>${orgItem.address}</td>
					
					<td>${orgItem.getRegisteredDateString()}</td>
					<td>${orgItem.getExpiredDateString()}</td>
					<td>${orgItem.alias}</td>
					<td>${orgItem.admin.name}</td>
					<td>${orgItem.admin.email}</td>
				</tr>
			</c:forEach>
		</table>
	</div>
</form>
</div>